<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    // 1. 替换字符 replace('被替换的字符'，'替换为字符')  它只会替换第一个字符
    var str = 'abcdeabc';
    console.log(str.replace('abc', '123'));

    // 有一个字符串'abcdefgadjskaslsa' 要求把里面所有的 a 替换成 *
    var str1 = 'abcdefgadjskaslsa';
    while (str1.indexOf('a') !== -1) {
      str1 = str1.replace('a', '*');
    }
    console.log(str1);

    // 2. 字符转换为数组 split('分隔符')  
    var str2 = 'red,blue,pink';
    console.log(str2.split(','));
    var str3 = 'skyblue&deeppink&black';
    console.log(str3.split('&'));
  </script>
</head>

<body>

</body>

</html>